<a href="<?=base_url("no_edit/video/add_video")?>" class="layui-btn layui-btn-lg layui-btn-normal" style="float: right;">新增</a>
<br><br><br>
<table class="layui-table">
    <colgroup>
        <col width="7%">
        <col width="8%">
        <col width="18%">
        <col width="7%">
        <col width="7%">
        <col width="12%">
        <col width="6%">
        <col width="15%">
    </colgroup>
    <thead>
    <tr>
        <th>关联图片</th>
        <th>视频模板</th>
        <th>标题</th>
        <th>分类</th>
        <th>话题</th>
        <th>添加时间</th>
        <th>状态</th>
        <th>操作</th>
    </tr>
    </thead>
    <tbody>
    <?php if(!empty($data['row'])){
        foreach($data['row'] as $k=>$v){
            ?>
            <tr>
                <input type="hidden" value="<?=$v['id']?>" class="id<?=$k+1?>">
                <td>
                    <img src="<?=$v['video_guanlian_pic']?>" style="width:80px;height:70px;" class="tom_show_image">
                </td>
                <td>
                    <img src="<?=$v['video_guanlian_pic']?>" style="width:80px;height:70px;" class="video<?=$k+1;?>">
                    <input type="hidden" value="<?=$v['video_url']?>" class="content<?=$k+1;?>">
                </td>
                <td><?=$v['video_title']?></td>
                <td><?=$v['fenlei_name']?></td>
                <td><?=$v['huati_name']?></td>
                <td><?=$v['add_time']?></td>
                <?php if($v['online']==1){ ?>
                    <td>下线</td>
                <?php }else if($v['online']==2){ ?>
                    <td>上线</td>
                <?php } ?>
                <td>
                    <a href="<?=base_url("no_edit/video/edit_add_video?id={$v['id']}")?>" class="layui-btn layui-btn-xs" style="margin-left:5px;margin-bottom:8px;">编辑</a>
                    <?php if($v['online']==2){ ?>
                        <button class="layui-btn layui-btn-xs layui-btn-warm stop<?=$k+1?>" style="margin-left:5px;margin-bottom:8px;">停用</button>
                    <?php }else if($v['online']==1){ ?>
                        <button class="layui-btn layui-btn-xs layui-btn-normal up<?=$k+1?>" style="margin-left:5px;margin-bottom:8px;">启用</button>
                    <?php } ?>
                    <button class="layui-btn layui-btn-xs layui-btn-danger del<?=$k+1?>" style="margin-left:5px;margin-bottom:8px;">删除</button>
                </td>
            </tr>
        <?php }}else{ ?>
        <tr>
            <td colspan="8" rowspan="3" style="color: #00CC00;font-size: 25px;height:100px;text-align: center;">暂无数据</td>
        </tr>
    <?php } ?>
    </tbody>
</table>
<div id="demo7"></div>
<script src="<?=SITE_BASE_URL?>/assets/plugins/dyj/layui_url.js"></script>

<script>
    $(function(){
        //定义一个51的jquery数组
        var arr=[];
        for(var i=1;i<51;i++){
            arr.push(i)
        }
        $.each(arr,function(i,n){
            var id=$(".id"+n).val();
            //停用
            $(".stop"+n).click(function(){
                $.ajax({
                    type:"post",
                    data:{id:id},
                    dataType: "json",
                    url:"<?=base_url("no_edit/video/stop")?>",
                    success:function(res){
                        if(res.code==0){
                            layer.msg(res.msg, {time: 2000},function(){
                                window.location.reload();
                            });
                        }else{
                            layer.msg(res.msg, {time: 2000});
                        }
                    }
                })
            })

            //启用
            $(".up"+n).click(function(){
                $.ajax({
                    type:"post",
                    data:{id:id},
                    dataType: "json",
                    url:"<?=base_url("no_edit/video/up")?>",
                    success:function(res){
                        if(res.code==0){
                            layer.msg(res.msg, {time: 2000},function(){
                                window.location.reload();
                            });
                        }else{
                            layer.msg(res.msg, {time: 2000});
                        }
                    }
                })
            })

            //移除
            $(".del"+n).click(function(){
                $.ajax({
                    type:"post",
                    data:{id:id},
                    dataType: "json",
                    url:"<?=base_url("no_edit/video/del")?>",
                    success:function(res){
                        if(res.code==0){
                            layer.msg(res.msg, {time: 2000},function(){
                                window.location.reload();
                            });
                        }else{
                            layer.msg(res.msg, {time: 2000});
                        }
                    }
                })
            })

            //移入缩略图显示和隐藏小手
            $('.video'+n).mouseover(function(){
                $(this).css("cursor","pointer")
            }).mouseout(function(){
                $(this).css("cursor","")
            })
            //视频放大
            $('.video'+n).click(function(){
                var content=$('.content'+n).val();
                var html="";
                html+="<video src='"+content+"' style=\"width:560px;height:400px;\" controls='controls' autoplay></video>"
                layer.open({
                    title:'视频播放'
                    ,content: html
                    ,area:['600px','540px']
                    ,btn: ['关闭']
                    ,yes: function(index, layero){
                        //按钮【按钮一】的回调
                        layer.close(index)
                    }
                    ,cancel: function(){
                        //右上角关闭回调

                        //return false 开启该代码可禁止点击该按钮关闭
                    }
                });
            })


        })

        //分页
        layui.use('laypage', function(){
            var laypage = layui.laypage;
            var param = GetRequest();
            //总页数大于页码总数
            laypage.render({
                elem: 'demo7'
                ,count:<?=$data['total']?>//数据总数
                ,curr: <?=$page?>
                ,limit:<?=$limit?>
                ,layout:  ['count', 'prev', 'page', 'next','limit', 'refresh', 'skip']
                ,jump: function(obj,first){
                    //首次不执行
                    if(!first){
                        var url = window.location.href;
                        url = url.substring(0, url.lastIndexOf('?'));

                        param['page'] = obj.curr;
                        param['limit'] = obj.limit;
                        window.location.href = createURL(url,param);
                    }
                }
            });
        });
    })
</script>